// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'; //element-ui 组件
import Mint from 'mint-ui'; //mint-ui组件
import axios from 'axios'
import 'mint-ui/lib/style.css'; //mint-ui的css样式，额外引入
import echarts from 'echarts' //百度的垃圾图表插件
import ApiCom from './Api/ApiCom.js' //←←←←引入公共API.js接口全在这儿
let wx = require('weixin-js-sdk'); //微信的麻烦到死skd
import alloylever from 'alloylever'; //开启vconsole。便于移动端调试
let bus = new Vue()


Vue.use(Mint);
Vue.use(ElementUI);
//Vue.prototype.$ajax = axios
Vue.prototype.bus = bus; //定义管道（非父子组件通信）
Vue.prototype.$alloylever = alloylever;

Vue.prototype.$wx = wx;
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.prototype.$ApiCom = ApiCom

/* eslint-disable no-new */
//wx.chooseImage    wx.previewImage     wx.uploadImage
/*路由守卫，在跳转路由之前的一系列操作，具体操作请阅以下注释*/

var headHtml = '<title>抱歉，出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">';
var bodyHtml = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信移动客户端打开链接</h4></div></div>'

function IsPC() {
  var userAgentInfo = navigator.userAgent;
  var Agents = ["Android", "iPhone",
    "SymbianOS", "Windows Phone",
    "iPad", "iPod"
  ];
  var flag = true;
  for (var v = 0; v < Agents.length; v++) {
    if (userAgentInfo.indexOf(Agents[v]) > 0) {
      flag = false;
      break;
    }
  }
  return flag;
}
// 
var s = false;
router.beforeEach((to, from, next) => {
  var ua = navigator.userAgent.toLowerCase();
  //判断是否是微信浏览器
  var isWeixin = ua.indexOf('micromessenger') != -1;
  var flag = IsPC();
  //判断是否是PC进入浏览器
  if (!flag) {
    //判断是否是微信进入浏览器
    if (!isWeixin) {
      document.head.innerHTML = headHtml;
      document.body.innerHTML = bodyHtml;
    } else {
      next();
    }
  } else {
    document.head.innerHTML = headHtml;
    document.body.innerHTML = bodyHtml;
  }

});




new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
